{% extends "base_index.html"%}
{% load i18n %}

{% comment %}
copyright (c) 2009, paketka@gmail.com et. al
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

	* Redistributions of source code must retain the above copyright notice,
	  this list of conditions and the following disclaimer.

	* Redistributions in binary form must reproduce the above copyright notice,
	  this list of conditions and the following disclaimer in the documentation
	  and/or other materials provided with the distribution.

	* Neither the name of the <ORGANIZATION> nor the names of its contributors
	  may be used to endorse or promote products derived from this software
 	  without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% endcomment %}

{% block keywords %}
, sněmovna {{ term.getStart }} - {{ term.getEnd }}, výkonost sněmovny, volební období
{% endblock %}
{% block js-links %}
	{{ block.super }}
	<script type="text/javascript" src="{{ MEDIA_URL }}/js/ui.accordion.js"></script>
{% endblock %}

{% block document-ready %}
{{ block.super }}

	$("#main-accordion").taccordion({
		collapsible: true,
		autoHeight: false,
		clearStyle: true,
		navigation: true,
		header: 'h2'
	});

	$("#main-accordion").taccordion('activate', -1);
	{% for board in boards %}
		{% with board.children.all as subboards %}
		{% ifnotequal subboards.count "0" %}
			$("#subBoard_{{ forloop.counter }}").taccordion({
				collapsible: true,
				autoHeight: false,
				clearStyle: true,
				navigation: true,
				header: 'h3'
			});
			$("#subBoard_{{ forloop.counter }}").taccordion('activate', -1);
		{% endifnotequal %}
		{% endwith %}
	{% endfor %}

	$('#mp-list').jqGrid({
				url:'{% url list_persons_json_term term.getStart,term.getEnd %}',
				datatype: 'json',
				colNames: [	"{% trans "Jméno" %}",
							"{% trans "Přijmení" %}",
							"{% trans "Věk" %}",
							"{% trans "Posl. klub" %}",
							"{% trans "Volební kraj" %}",
							"{% trans "Nepřítomnost [%]" %}",
					],
				colModel :[
					{ name: "name", index: "person__name", width: 120, jsonmap: "name", sortable: true, search: true },
					{ name: "surname", index: "person__surname", width:120, jsonmap:"surname", sortable: true, search: false },
					{ name: "age", index: "person__birthDate", width: "30", align: "center", jsonmap:"age", sortable: true, search: false },
					{ name: "club", index: "group__name", width: "70", align: "center", jsonmap:"mpClub", sortable: true, search: false },
					{ name: "division", index: "division", width: "100", align: "center", jsonmap:"divName", sortable: true, search: false },
					{ name: "absences", index: "absences", width: 50, align: "center", jsonmap: "absences", sortable: true, search: false }
				], 
				pager: $('#mp-pager'),
				jsonReader: {
					root: "rows",
					id: "pk",
					page: "page",
					total: "total",
					records: "records",
					repeatitems: false
				},
				sortname:"person__surname",
				sortorder:"asc",
				rowNum:10,
				rowList:[10,15,20],
				viewrecords:true,
				caption:"{% trans "Seznam poslanců" %} {{ term.getStart }} - {{ term.getEnd }}",
				width: 780,
				toolbar: [true,'top']
	});

	$('#t_mp-list').filterGrid('#mp-list', {
				gridModel: false,
				gridToolBar: false,
				filterModel: [ {
					label: '',
					name: 'filter__exp',
					stype: 'text',
					defval: ''
				} ],
				autosearch: true,
				searchButton: '{% trans "Hledej" %}',
				enableSearch: true
			}
		);

{% endblock document-ready %}
{% block main-tab %}

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Parlament" %} {{ term.getStart }} - {{ term.getEnd }}</h2>
	</div>
	<div class="ui-widget-content">
		<p>
			{% blocktrans %}
			Během období v <a href="http://www.psp.cz">parlamentu</a> proběhlo
			{{ totalPolls }} hlasování během {{ totalMeetings }} schůzí. V poslaneckých
			lavicích zasedlo {{ mpTotal }} poslanců. Průměrný věk každého poslance
			byl {{ avgAge }}. Poslanci byli rozsazeni do {{ orgCount }} parlamentních
			organizací. Průměrně zmeškali {{ absences }}% hlasování.
			{% endblocktrans %}
		</p>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Recyklace" %} {{ term.getStart }} - {{ term.getEnd }}</h2>
	</div>
	<div class="ui-widget-content">
		<div class="left">
			{{ recycle.img|safe }}
		</div>
		<div class="right">
			<p> {% blocktrans with term.getStart as start and term.getEnd as end %}
				Graf vlevo zobrazuje poměr mezi nově zvolenými (zelenáči) a zrecyklovanými
				(veteráni) poslanci pro období ({{ start }} - {{ end }}).
				{% endblocktrans %}
			</p>
		</div>
		<div class="clear"></div>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Poměr mužů a žen" %} {{ term.getStart }} - {{ term.getEnd }}</h2>
	</div>
	<div class="ui-widget-content">
		<div class="left">
			{{ fmRatio.img|safe }}
		</div>
		<div class="right">
			<p> {% blocktrans %}
				A jak se dělí o zákonodárnou moc muži a ženy v tomto volebním období.
				{% endblocktrans %}
			</p>
		</div>
		<div class="clear"></div>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Stranické kluby" %} {{ term.getStart }} - {{ term.getEnd }}</h2>
	</div>
	<div class="ui-widget-content">
		<div class="left">
			{{ mpClubs.img|safe }}
		</div>
		<div class="right">
			{{ mpAge.img|safe }}
		</div>
		<div class="clear"></div>
		<div class="left">
			<p> {% blocktrans %}
				Rozložení politických sil v parlamentu. Záznamy nemusí být přesné,
				neboť jak je známo někteří poslanci stranické kluby během funkčního období
				opouštějí a zákládají nové kluby a frakce. Graf je vztažen k poslednímu
				datu daného volebního období. Nemusí se tedy shodovat s výsledkem voleb,
				neboť mnozí poslanci z klubů vystupují a zakládají nové nezávislé rebelující
				frakce.
				{% endblocktrans %}
			</p>
		</div>
		<div class="right">
			<p> {% blocktrans %}
				Graf ukazuje průměrný věk v jednotlivých stranických klubech.
				Graf opět vychází ze stavu po volbách.
				{% endblocktrans %}
			</p>
		</div>
		<div class="clear"></div>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Seznam poslanců" %} {{ term.getStart }} - {{ term.getEnd }}</h2>
	</div>
	<div class="ui-widget-content">
		<table id="mp-list" class="scroll" cellpadding="0" cellspacing="0">
		</table>
		<div id="mp-pager" class="scroll" style="text-align:center;"></div>
	</diV>
</div>

<div id="main-accordion">
{% if boards|length %}
	<h2><a href="#null">{% trans "Výbory a podvýbory" %} {{ term.getStart }} - {{ term.getEnd }}</a></h2>
	<div><p>
		{% for board in boards %}
			{% with board.children.all as subboards %}
			{% ifequal subboards.count "0" %}
				<h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
					<a href="{% url psp.views.show_group board.slug %}"> {{ board.name }}</a>
				</h3>
			{% else %}
				<div id="subBoard_{{ forloop.counter }}"> 
					<h3><a href="#void">{{ board.name }}</a></h3>
					<div>
						<p>
							<a href="{% url psp.views.show_group board.slug %}">{{ board.name }}</a>
						</p>
						{% for subBoard in subboards %}
							<p>
							<a href="{% url psp.views.show_group subBoard.slug %}">{{ subBoard.name }}</a>
							</p>
						{% endfor %} 
					</div>
				</div>
			{% endifequal %}
			{% endwith %}
		{% endfor %}
	</p></div>
{% endif %}

{% if committees|length %}
	<h2><a href="#null">{% trans "Komise" %} {{ term.getStart }} - {{ term.getEnd }}</a></h2>
	<div>
		{% for committee in committees %}
			<p><a href="{% url psp.views.show_group committee.slug %}">{{ committee.origName }}</a></p>
		{% endfor %}
	</div>
{% endif %}

{% if mpuGroups|length %}
	<h2><a href="#null">{% trans "Skupiny meziparlamentární unie (MPU)" %} {{ term.getStart }} - {{ term.getEnd }}</a></h2>
	<div>{% for mpu in mpuGroups %}
			<p><a href="{% url psp.views.show_group mpu.slug %}">{{ mpu.origName }}</a></p>
		{% endfor %}
	</div>
{% endif %}

{% if delegs|length %}
	<h2><a href="#null">Delegace {{ term.getStart }} - {{ term.getEnd }}</a></h2>
	<div>
		{% for d in delegs %}
			<p><a href="{% url psp.views.show_group d.slug %}">{{ d.origName }}</a></p>
		{% endfor %}
	</div>
{% endif %}

{% if rest|length %}
	<h2><a href="#null">{% trans "Ostatní" %} {{ term.getStart }} - {{ term.getEnd }}</a></h2>
	<div>
		{% for i in rest %}
			<p><a href="{% url psp.views.show_group i.slug %}">{{ i.origName }}</a></p>
		{% endfor %}
	</div>
{% endif %}
</div>

{% endblock main-tab %}
